package com.flong.spring.annotation;

import com.flong.spring.bean.Student;
import com.flong.spring.filter.MyFilter;
import com.flong.spring.service.StudentService;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;

/**
 * @Author:liangjl
 * @Date: 2020/6/10-18:50
 * @Eamil:jilongliang@sina.com
 * @Description: -------------------------------------------
 * Configuration 告诉Spring这是一个配置
 * excludeFilters 指定扫描的时候按照什么规则排除拿行组件
 * includeFilters 指定扫描的时候只需要包含哪些组件
 * useDefaultFilters禁掉默认扫描
 * FilterType.ANNOTATION按照注解
 * FilterType.ASSIGNABLE_TYPE按照规定的类型
 * FilterType.ASPECTJ使用ASPECTJ表达式
 * FilterType.REGEX 使用正则表达式
 * FilterType.CUSTOM 开发自定义规则
 * -------------------------------------------
 */
@Configuration
@ComponentScans(value = {
        @ComponentScan(value = "com.flong", excludeFilters = {
                //@ComponentScan.Filter(type = FilterType.ANNOTATION, classes = { Controller.class }),
                //@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = { StudentService.class }),
                @ComponentScan.Filter(type = FilterType.CUSTOM, classes = {MyFilter.class})
        }, useDefaultFilters = false)
})
public class StudentConfig {

    @Bean(value = "student")
    public Student getStudent() {
        return Student.builder().age(90).userName("一灯大师").build();
    }
}
